package cn.itsource.pethome.org.service.impl;

import cn.itsource.pethome.org.constant.Constant;
import cn.itsource.pethome.basic.service.impl.BaseServiceImpl;
import cn.itsource.pethome.org.domain.Employee;
import cn.itsource.pethome.org.domain.Shop;
import cn.itsource.pethome.org.mapper.EmployeeMapper;
import cn.itsource.pethome.org.mapper.ShopMapper;
import cn.itsource.pethome.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @description: 描述:
 * @date: 2020/8/11 16:15
 * @author: summer
 * version: 1.0
 */
@Service
public class ShopServiceImpl extends BaseServiceImpl<Shop> implements IShopService {

    @Autowired
    private ShopMapper shopMapper;

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    @Transactional
    public void settledIn(Shop shop) {
        Employee admin = shop.getAdmin();
        admin.setState(Constant.EMP_AUDIT);
        System.out.println("service层测试："+admin);
        employeeMapper.save(admin);

        shop.setAdmin(admin);
        shopMapper.settledIn(shop);
    }

    @Override
    public Shop loadByEmployee(Employee employee) {
        return shopMapper.loadByEmployee(employee.getId());
    }
}
